package com.lin.commons;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @Author Created by Lin Weihong
 * @Time on 2021/11/24 12:26
 */
@Data
@NoArgsConstructor
public class Result<T> implements Serializable {
    private Integer code;
    private String msg;
    private T data;

    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static<T> Result success(T data) {
        return new Result(200,"操作成功",data);
    }

    public static<T> Result success(String msg) {
        return new Result(200,msg,null);
    }

    public static<T> Result success() {
        return new Result(200,"操作成功",null);
    }

    public static<T> Result failure() {
        return new Result(500, "服务端异常", null);
    }

    public static<T> Result failure(String msg) {
        return new Result(500, msg, null);
    }


}
